package persistence;

import java.io.File;
import java.util.List;
import java.util.Map;

import model.Filter;
import model.EmailImp;
import model.MeetingInfo;
import model.Template;
import model.User;

/**
 * interface for persistence manager
 *
 */
public interface PersistenceManagerImp
{
    /**
     * persist email to file
     * @param email the email
     * @param persistPath the persistence path
     */
    public void persistEMail(EmailImp email, String persistPath);
    
    /**
     * persist user account/information to file
     * @param user the user object
     */
    public void persistUserAccount(User user);
    
    /**
     * delete file from the system from the given path
     * @param fileToDeletePath the file to delete path
     * @return return true if the file is deleted successfully else false
     */
    public boolean deleteFile(String fileToDeletePath);

    /**
     * move file from given source path to destination path
     * @param sourceFilePath the source file path
     * @param destrinationFilePath the destination file path
     */
    public void moveToFile(String sourceFilePath, String destrinationFilePath);
    
    /**
     * copy file from source path to destination path
     * @param sourceFilePath the source file path
     * @param destrinationFilePath the destination file path
     */
    public void copyFile(String sourceFilePath,String destrinationFilePath);
    
    /**
     * get email files from the folder - do not iterate all folders inside
     * @param path the given path
     * @return the list of the email(s) in the given path
     */
    public List<File> getEmailFilesFromFolder(String path);
    
    /**
     * get all email files from inside the folders - iterate all folders inside
     * @param path the given path
     * @return the list of the email(s) in the given path
     */
    public List<File> getEmailFilesDeepInsideFolder(String path);
    
    /**
     * create file of the given path
     */
    public void createFile(String path);
    
    /**
     * delete all the files inside the given path
     * @param the given path
     */
    public void deleteFiles(String path);
    
    /**
     * check is email id registered, return true is yes, otherwise return no
     * @param emailId the email id
     * @return return true if the email id registered
     */
    public boolean isEmailIdRegistered(String emailId);
    
    /**
     * check if the email id and password are matching, return true if yes, otherwise return false
     * @param emailID the email id
     * @param password the password
     * @return
     */
    public boolean isValidUser(String emailID, String password);
    
    /**
     * get templates from the given folder path
     * @param directoryPath the directory path
     * @return list of template
     */
    public List<Template> getTemplateFromFolder(String directoryPath);
    
    /**
     * get filters from the given folder path
     * @param directoryPath the directory path
     * @return list of filter
     */
    public List<Filter> getFilterFromFolder(String directoryPath);
    
    
    /**
     * This method writes 'Template' Java objects as JSON files in a local directory. 
     * @param template a template object to be passed to be written as a template.json file in the Template directory.
     * @param templatePath is the Template directory file-path passed as string.
     */
    public void writeTemplateAsFile(Template template, String templatePath);
    
    /**
     * This method writes 'Filter' Java objects as JSON files in a local directory. 
     * @param filter a filter object to be passed to be written as a "filter name".json file in the Filters directory.
     * @param filterPath is the Filter directory file-path passed as string.
     */
    public void writeFilterAsFile(Filter filter, String filterPath);
    
    /**
     * get email(s) whose content matches with the query string
     * @param user the user
     * @param query the query/search keyword
     * @return list of files which has passed the search result
     */
    public List<File> getSearchResult(String user, String query, boolean isRegEx);
    
    /**
     * get advanced search result
     * @param user the user
     * @param query the query keyword
     * @param SearchType the search type
     * @return return the advanced search results in the map
     */
    public Map<String,File> getAdvancedSearchResult(String user, String query, int SearchType);
    
    /**
     * to convert JSON to email file
     * @param path the given path
     * @return to return the EmailImp object
     */
    public EmailImp emailJsonToEmailImp(String path);
    
    /**
     * to persist the meeting information
     * @param info meeting information
     * @param path the given path
     */
    public void persistMeetingInfo(MeetingInfo info, String path);

    /**
     * get all persist meeting information files
     * @param rootFolderPath the given path
     * @return list of MeetingInfo found in the given path
     */
    public List<MeetingInfo> getPersistMeetingInfo(String rootFolderPath);

    /**
     * get meeting information, MeetingInfo
     * @param meetingPath the given meeting path
     * @return the MeetingInfo object
     */
    public MeetingInfo getMeetingInfo(String meetingPath);

}